import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		hasLogin: uni.getStorageSync("token")?true:false,
	},
	mutations: {
		
		login(state, token) {
			state.hasLogin = true;

			uni.setStorage({ //缓存用户登陆状态
				key: 'token',
				data: token
			})
		},
		logout(state) {
			state.hasLogin = false;
			uni.removeStorage({
				key: 'token'
			})
		}
	},
	actions: {

	}
})

export default store
